import request from '../tools/request'
//添加药品分内
//admin/medicine categories
export function addMedicineAPI(data) {
  return request({
    url: '/admin/medicine_categories',
    method: 'post',
    data
  }).then((res) => res)
}
//获取药品列表
///admin/medicine categories
export function getMedicineAPI(page = 1, per = 10) {
  return request({
    url: '/admin/medicine_categories',
    method: 'get',
    params: { page, per }
  }).then((res) => res.data)
}
//根据分类获取
//admin/medicine categories
// export function getMedicineAPI(id,page=1,per=20) {
//   return request({
//     url: `/admin/medicine_categories/${id}`,
//     method: 'get',
//     params:{page,per},
//   }).then((res) => res.data)
// }

//搜索
//admin/medicine_categories
export function getMedicinessAPI(name = '', page = 1, per = 10) {
  return request({
    url: '/admin/medicine_categories',
    method: 'get',
    params: { name, page, per }
  }).then((res) => res.data)
}

//删除
///admin/medicine_categories/{id}
export function delMedicineAPI(id) {
  return request({
    url: `/admin/medicine_categories/${id}`,
    method: 'delete'
  }).then((res) => res)
}
//修改
//admin/medicine_categories/{id}
export function editMedicineAPI(id, data) {
  return request({
    url: `/admin/medicine_categories/${id}`,
    method: 'patch',
    data
  }).then((res) => res)
}
//获取药品列表
///admin/medicines
export function getMedicineListAPI(page = 1, per = 40) {
  return request({
    url: '/admin/medicines',
    method: 'get',
    params: { page, per }
  }).then((res) => res.data)
}
//搜索
//admin/medicines
export function getMedicineListsAPI(name = '', page = 1, per = 30) {
  return request({
    url: '/admin/medicines',
    method: 'get',
    params: { name, page, per }
  }).then((res) => res.data)
}
//新增
///admin/medicines
export function addMedicineListAPI(data) {
  return request({
    url: '/admin/medicines',
    method: 'post',
    data
  }).then((res) => res)
}
//删除
///admin/medicines/{id}
export function delMedicineListAPI(id) {
  return request({
    url: `/admin/medicines/${id}`,
    method: 'delete'
  }).then((res) => res)
}
//修改
///admin/medicines/{id}
export function editMedicineListAPI(id, data) {
  return request({
    url: `/admin/medicines/${id}`,
    method: 'patch',
    data
  }).then((res) => res)
}
//点击获取
///admin/medicines/{id}
export function getMedicineListIdAPI(id) {
  return request({
    url: `/admin/medicines/${id}`,
    method: 'get'
  }).then((res) => res.data)
}
//加入购物车
///members/shop_carts
export function addShopCartAPI(data) {
  return request({
    url: '/members/shop_carts',
    method: 'post',
    data
  }).then((res) => res)
}
//获取分类
///medicines/categories
export function getMedicineCategoryAPI() {
  return request({
    url: '/medicines/categories',
    method: 'get',
  }).then((res) => res.data)
}
//获取药品信息
///medicines
export function getMedicineAPIs(page=1,per=20) {
  return request({
    url: '/medicines',
    method: 'get',
    params:{page,per},
  }).then((res) => res.data)
}
//分内
///medicines/{id}s
export function getMedicineAPIIs(category,page=1,per=20) {
  return request({
    url: `/medicines?category=${category}`,
    method: 'get',
    params:{page,per},
  }).then((res) => res.data)
}
//详情
///medicines/{id}getMedicineAPIId
export function getMedicineAPIId(id) {
  return request({
    url: `/medicines/${id}`,
    method: 'get',
  }).then((res) => res.data)
}
//购物车数据
///members/shop carts
export function getShopCartAPI() {
  return request({
    url: '/members/shop_carts',
    method: 'get',
  }).then((res) => res.data)
}
//多选删除
///members/shop_carts
export function deleteShopCartAPI(id) {
  return request({
    url: `/members/shop_carts?id=${id}`,
    method: 'delete',
  
  }).then((res) => res)
}
//轮播图添加
///admin/illness_categories
export function addIllnessAPI(data) {
  return request({
    url: '/admin/illness_categories',
    method: 'post',
    data
  }).then((res) => res)
}
//获取轮播图列表
export function getIllnessAPI(page=1,per=20) {
  return request({
    url: '/admin/illness_categories',
    method: 'get',
    params:{page,per},
  }).then((res) => res.data)
}
//轮播图修改
///admin/illness categories/iid}
export function editIllnessAPI(id,data) {
  return request({
    url: `/admin/illness_categories/${id}`,
    method: 'patch',
    data
  }).then((res) => res)
}
//轮播图删除
///admin/illness categories/{id}
export function delIllnessAPI(id) {
  return request({
    url: `/admin/illness_categories/${id}`,
    method: 'delete',
  }).then((res) => res)
}
//搜索
export function getIllnesssAPI(name="",page=1,per=20) {
  return request({
    url: '/admin/illness_categories',
    method: 'get',
    params:{name,page,per},
  }).then((res) => res.data)
}
//轮播图前台
///illnesses/categories
export function getIllnesssAPIs(page=1,per=20) {
  return request({
    url: '/illnesses/categories',
    method: 'get',
    params:{page,per},
  }).then((res) => res.data)
}






